package com.shire.shire_interface.service.invite;

import com.shire.shire_interface.dao.invite.WxInviteSubTaskDao;
import com.shire.shire_interface.model.invite.WxInviteSubTask;
import com.shire.shire_interface.model.invite.WxInviteSubTaskExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 作者:  sll
 * 时间:  2019/8/9 15:42
 */
@Service
public class WxInviteSubTaskService {

    @Resource
    private WxInviteSubTaskDao wxInviteSubTaskDao;

    public int updateSubTaskRststatus(Integer id, Integer rstStatus){
        WxInviteSubTask subTask = wxInviteSubTaskDao.selectByPrimaryKey(id);
        if (subTask == null)
            return -1;
        subTask.setRststatus(rstStatus);
        subTask.setUpdatetime(new Date());
        if (rstStatus != -999 && rstStatus != -100 && rstStatus != 0){
            subTask.setAddstatus(3);
        }
        return wxInviteSubTaskDao.updateByPrimaryKeySelective(subTask);
    }


    public List<WxInviteSubTask> getInviteHistory(WxInviteSubTaskExample example) {

        return wxInviteSubTaskDao.selectByExample(example);
    }

    public int insert(WxInviteSubTask wxInviteSubTask) {

        return wxInviteSubTaskDao.insertSelective(wxInviteSubTask);
    }
}
